<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>
    <!-- <script type="text/javascript" src="/assets/js/angular.min.js"></script> -->
    <!-- <link rel="stylesheet" type="text/css" href="/assets/css/bootstrap.min.css"> -->
    <!-- <link rel="stylesheet" type="text/css" href="/assets/font/font-awesome.min.css"> -->
    <script type="text/javascript" charset="utf-8" src="/assets/js/angular.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/assets/js/jquery.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/assets/js/ui-bootstrap-tpls.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/node_modules/angular-ui-router/release/angular-ui-router.js"></script>
    <script type="text/javascript" charset="utf-8" src="/assets/layer/layer.js"></script>
    <script type="text/javascript" charset="utf-8" src="/assets/laydate/laydate.js"></script>
    <link rel="stylesheet" type="text/css" href="/assets/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="/assets/fonts/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="/assets/css/custom.css" />
</head>

<body>


    <div class="width-1200 form-horizontal" ng-app="myApp" ng-controller="siteCtrl">
        <div class="form-group" style="margin-top: 200px;">
            <div class="col-sm-offset-5 col-sm-2">
                <button class="btn btn-success btn-block" type="button" ng-click="one_url()"><i class="fa fa-search"></i>&nbsp;拿路径</button>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 col-sm-offset-3">
                <input type="text" placeholder="请输入表名" ng-model="search_data.table_name" class="form-control" />
            </div>
            <div class="col-sm-2">
                <button class="btn btn-success btn-block" type="button" ng-click="take_search()"><i class="fa fa-search"></i>&nbsp;查数据</button>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-5 col-sm-2">
                <button class="btn btn-success btn-block" type="button" ng-click="test_works()"><i class="fa fa-search"></i>&nbsp;抓作品</button>
            </div>
        </div>

        <ul class="list-unstyled">
            <li ng-repeat="d in data">{{d.works_content_url}}</li>
        </ul>
        
    </div>

    <script type="text/javascript">
    var app = angular.module('myApp', ['ui.bootstrap']);

    app.controller('siteCtrl', function($scope, $http, $uibModal) {

        $scope.search_data = {
            table_name:'works_code',
            action: ''
        };


        // 更新
        $scope.one_url = function() {
            $scope.search_data = {
                // site: 'http://www.nanrenvip8.net/find.html',
                // action: 'visit_site'
            };
            $scope.get_data();
        };

        $scope.works = function() {
            // body...
            $scope.search_data = {
                action: ''
            };
            $scope.get_data();
        }

        // 拿作品信息
        // $scope.take_works =function(callback) {
        //     // body...
        //     $scope.search_data = {
        //         data: $scope.one_arr[0],
        //         action: 'take_works'
        //     };
        //     $scope.post_take_works($scope.take_works_callback);
        // }
        // $scope.take_works_callback = function(callback) {
        //     // body...
        //     if ($scope.take_state) {
        //         $scope.splice_arr();
        //     }else{
        //         console.log('stop');
        //     }
        // }
        // // 拿作品请求
        // $scope.post_take_works = function(callback) {
        //     // body...
        //     $http({
        //         method: 'POST',
        //         url: 'index.php',
        //         data: $scope.search_data
        //     }).then(function successCallback(response) {
        //         $scope.take_state = response.data;
        //         callback($scope.take_state);
        //     }, function errorCallback(response) {
        //         // 请求失败执行代码
        //         console.log("请求数据库失败")
        //     });
        // };


        // 拿演员简介
        // $scope.grab_works = function(callback) {
        //     // body...
        //     $scope.search_data = {
        //         data: $scope.one_arr[0],
        //         action: 'take_describe'
        //     }
        //     $scope.take_works_data($scope.for_callback);
        // }
        // $scope.for_callback = function() {
        //     // body...
        //     if ($scope.take_state) {
        //         $scope.splice_arr();
        //     }else{
        //         console.log('stop');
        //     }

        // }
        // // 初始化查询
        // $scope.take_works_data = function(callback) {
        //     // body...
        //     $http({
        //         method: 'POST',
        //         url: 'index.php',
        //         data: $scope.search_data
        //     }).then(function successCallback(response) {
        //         $scope.take_state = response.data;
        //         callback($scope.take_state);
        //     }, function errorCallback(response) {
        //         // 请求失败执行代码
        //         console.log("请求数据库失败")
        //     });
        // };




        // // 下载作品图片
        // $scope.take_image =function(callback) {
        //     // body...
        //     $scope.search_data = {
        //         data: $scope.one_arr[0],
        //         action: 'take_image'
        //     };
        //     $scope.post_take_image($scope.take_works_callback);
        // }
        // $scope.take_works_callback = function(callback) {
        //     // body...
        //     if ($scope.take_state) {
        //         $scope.splice_arr();
        //     }else{
        //         console.log('stop');
        //     }
        // }
        // // 拿作品请求
        // $scope.post_take_image = function(callback) {
        //     // body...
        //     $http({
        //         method: 'POST',
        //         url: 'index.php',
        //         data: $scope.search_data
        //     }).then(function successCallback(response) {
        //         $scope.take_state = response.data;
        //         callback($scope.take_state);
        //     }, function errorCallback(response) {
        //         // 请求失败执行代码
        //         console.log("请求数据库失败")
        //     });
        // };

        // 获取作品详情
        $scope.take_works_content =function(callback) {
            // body...
            $scope.search_data = {
                data: $scope.one_arr[0],
                action: 'take_works_content'
            };
            $scope.post_works_content($scope.take_works_content_callback);
        }
        $scope.take_works_content_callback = function(callback) {
            // body...
            if ($scope.take_state) {
                $scope.splice_arr();
            }else{
                console.log('stop');
            }
        }
        // 拿作品请求
        $scope.post_works_content = function(callback) {
            // body...
            $http({
                method: 'POST',
                url: 'index.php',
                data: $scope.search_data
            }).then(function successCallback(response) {
                $scope.take_state = response.data;
                callback($scope.take_state);
            }, function errorCallback(response) {
                // 请求失败执行代码
                console.log("请求数据库失败")
            });
        };



        $scope.take_search =function(callback) {
            // body...
            $scope.search_data.action = "take_search";
            $scope.get_data($scope.splice_arr);
        }
        $scope.splice_arr = function() {
            // body...
            // console.log($scope.data);
            $scope.one_arr = $scope.data.splice([0],[1]);
            if (!$scope.one_arr[0].works_image) {
                console.log('第'+$scope.one_arr[0].id+'个，是空的，名字是'+$scope.one_arr[0].actress_name);
                $scope.one_arr = $scope.data.splice([0],[1]);
            }
            // 拿演员简介
            // $scope.grab_works();
            // 拿作品信息
            // $scope.take_works()
            // 下载图片作品
            // $scope.take_image();
            // 获取作品详情
            $scope.take_works_content();
        }
        // 初始化查询
        $scope.get_data = function(callback) {
            // body...
            $http({
                method: 'POST',
                url: 'index.php',
                data: $scope.search_data
            }).then(function successCallback(response) {
                $scope.data = response.data;
                callback($scope.data);
            }, function errorCallback(response) {
                // 请求失败执行代码
                console.log("请求数据库失败")
            });
        };

    });

    </script>    




</body>
</html>